package com.foreknow.demo2;

import java.util.Scanner;

/**
 * while循环
 */
public class LoopDemo2 {
    public static void main(String[] args) {
//        int x = 1;
//        while (x <= 10) {
//            System.out.println(x);
//            x++;
//        }
//        System.out.println("over......");

        System.out.println("*****************shopping*********************");
        System.out.println("        请选择你要购买的商品编号: ");
        System.out.println("    1. fender     2. gibson    3. yamaha");
        System.out.println("*****************shopping*********************");

        String name = ""; //商品的名称
        double price = 0.0; //商品的价格
        String answer = "y"; //标识是否继续
        Scanner input = new Scanner(System.in);
        while ("y".equals(answer)) {
            System.out.println("请选择你要购买的商品编号: ");
            int goodNo = input.nextInt();
            switch (goodNo) {
                case 1:
                    name = "fender";
                    price = 5000.50;
                    break;
                case 2:
                    name = "gibson";
                    price = 15000.50;
                    break;
                case 3:
                    name = "yamaha";
                    price = 3000.50;
                    break;
            }
            System.out.println(name + "-----" + price);
            System.out.println("是否继续(y/n)");
            answer = input.next();
        }
    }
}
